package com.ht.medicaltreatment.adapter

import android.graphics.Color
import android.view.View
import android.widget.TextView
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.viewholder.BaseViewHolder
import com.ht.medicaltreatment.R
import com.ht.medicaltreatment.bean.OrderAllBean

class OrderFragmentAdapter :BaseQuickAdapter<OrderAllBean,BaseViewHolder>(R.layout.item_order_fragment_layout) {
    override fun convert(holder: BaseViewHolder, item: OrderAllBean) {
        val root = holder.getView<View>(R.id.llTitle)
        val tvStatus = holder.getView<TextView>(R.id.tvStatus)
        val position = getItemPosition(item)
        holder.setText(R.id.tvOrderName,item.assetCheckOrderName)
        if(item.createTime != null){
            val arr = item.createTime.split(" ")
            if(arr.size > 0){
                holder.setText(R.id.tvTime,arr[0])
            }
        }
        if(position % 2 == 0){
            root.setBackgroundColor(Color.parseColor("#BBD3FF"))
        }else{
            root.setBackgroundColor(context.getColor(R.color.whiteBg))
        }

        if(item.status == 0){
            tvStatus.text="缺失"
            tvStatus.setTextColor(context.getColor(R.color.red))
        }else{
            tvStatus.text="正常"
            tvStatus.setTextColor(context.getColor(R.color.green))
        }
    }

}
